package com.cs.framework.core.context;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.InitializingBean;

import com.cs.framework.core.util.CoreConstant;

/**
 * 模块池
 * 
 * @author hedongzhou
 * 
 */
public class ModulePool implements InitializingBean {

	/**
	 * 模块信息，key为模块ID，value为模块包路径
	 */
	protected Map<String, String> moduleMap;

	/**
	 * 模块信息，value为“模块ID;模块包路径”
	 */
	protected List<String> moduleList;

	public ModulePool() {
	}

	public Map<String, String> getModuleMap() {
		return moduleMap;
	}

	public void setModuleMap(Map<String, String> moduleMap) {
		this.moduleMap = moduleMap;
	}

	public List<String> getModuleList() {
		return moduleList;
	}

	public void setModuleList(List<String> moduleList) {
		this.moduleList = moduleList;
	}

	public void afterPropertiesSet() throws Exception {
		if (moduleList != null && moduleList.size() > 0) {
			moduleMap = new HashMap<String, String>();

			for (String info : moduleList) {
				String[] arr = info.split(CoreConstant.CONF_SEPARATE);
				moduleMap.put(arr[0], arr[1]);
			}
		}
	}

}
